package org.work;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import org.model.Xsb;

public class DBConn {
	Connection conne;

	PreparedStatement pstmt;

	public DBConn() {
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			conne = DriverManager.getConnection(
					"jdbc:sqlserver://localhost:1433;" + "databaseNam=XSCJ",
					"liuyanbo", "123456");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public boolean save(Xsb xs) {
		try {
			pstmt = conne
					.prepareStatement("insert into XSB value(?,?,?,?,?,?)");
			pstmt.setString(1, xs.getXh());
			pstmt.setString(2, xs.getXm());
			pstmt.setByte(3, xs.getXb());
			pstmt.setString(4, xs.getZy());
			pstmt.setDate(5, xs.getCssj());
			pstmt.setString(6, xs.getBz());
			pstmt.executeUpdate();
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

}
